﻿using Autofac;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Common
{
    public class AutoFacManage:Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            var iapirepository = Assembly.Load("DFGK.Repository");

            var iapiservice = Assembly.Load("DFGK.Service");

            builder.RegisterAssemblyTypes(iapirepository).Where(t => t.Name.EndsWith("Repository")).AsImplementedInterfaces();

            builder.RegisterAssemblyTypes(iapirepository).Where(t => t.Name.EndsWith("UnitOfWork")).AsImplementedInterfaces();

            builder.RegisterAssemblyTypes(iapiservice).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces();

            builder.RegisterType<JwtSecurityTokenHandler>().SingleInstance();
            builder.RegisterType<TokenHelper>().SingleInstance();

        }
    }
}
